﻿using Newtonsoft.Json;
using Yitter.IdGenerator;

namespace Rabbit.API
{
    /// <summary>
    /// 静态扩展
    /// </summary>
    public static class Expandway
    {
        /// <summary>
        /// 序列化
        /// </summary>
        /// <typeparam name="T">集合</typeparam>
        /// <param name="list"></param>
        /// <returns>字符串</returns>
        public static string Getstr(this List<int> list)
        {
            return JsonConvert.SerializeObject(list);
        }
        /// <summary>
        /// 反序列化
        /// </summary>
        /// <typeparam name="T">字符串</typeparam>
        /// <param name="str"></param>
        /// <returns>集合</returns>
        public static List<int> Getlist(this string str)
        {
            return JsonConvert.DeserializeObject<List<int>>(str);
        } 
        /// <summary>
        /// 获取雪花ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static long GetSnowId(this long id)
        {
            return id = YitIdHelper.NextId();
        }
    }
}
